package com.yanqu.road.server.cmd.union.cross;

import com.yanqu.road.pb.union.Parergon;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.union.CrossUnionParergonMgr;
import com.yanqu.road.server.manager.union.CrossUnionReqContext;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_UNION_PARERGON_OPERATE_RECORD, desc = "经营记录")
public class CrossOperateRecordCmd extends CrossCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

        CrossUnionReqContext context = CrossUnionReqContext.initContext(serverId, packet.getPlayerId()).loadUnionMember().loadUnionInfo();

        Parergon.OperateRecordRespMsg.Builder respMsg;
        if (context.getRet() != 0) {
            respMsg = Parergon.OperateRecordRespMsg.newBuilder();
        } else {
            respMsg = CrossUnionParergonMgr.getOperateRecord(context.getUnionInfo().getUnionUid());
        }
        respMsg.setRet(ret);


        MessageHelper.sendPacket(serverId, packet.getPlayerId(), YanQuMessageUtils.buildMessage(Protocol.U_UNION_PARERGON_OPERATE_RECORD, respMsg));
    }

    @Override
    public void sendData() {

    }
}
